import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
// 导入树状图表格
import TreeTable from 'vue-table-with-tree-grid'
// 导入富文本编辑器
import vueQuillEditor from 'vue-quill-editor'
// import Interface from './plugins/interface'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

import NProgress from 'nprogress'
// import 'nprogress/nprogress.css'

// import echarts from 'echarts'

Vue.config.productionTip = false

// 配置axios默认访问链接
axios.defaults.baseURL = 'https://www.dapmix.top/api/'
axios.interceptors.request.use(config => {
  NProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
Vue.prototype.$http = axios

// Vue.prototype.$echart = echarts

// Vue.prototype.$interface = Interface

Vue.config.productionTip = false

Vue.component('tree-table', TreeTable)

Vue.use(vueQuillEditor)

Vue.filter('dataFormat', function(originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1).toString().padStart(2, '0')
  const d = (dt.getDate() + 1).toString().padStart(2, '0')
  const hh = (dt.getHours() + 1).toString().padStart(2, '0')
  const mm = (dt.getMinutes() + 1).toString().padStart(2, '0')
  const ss = (dt.getSeconds() + 1).toString().padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
